package Practice;

import java.util.Scanner;

public class Make {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w,x,h;
        w = sc.nextInt();
        x = sc.nextInt();
        h = sc.nextInt();
        int q = sc.nextInt();
        int[] a = new int[6];
        int[][][] glass = new int[21][21][21];
        for (int i = 1; i <= w; i++) {
            for (int j = 1; j <= x; j++) {
                for (int k = 1; k <= h; k++) {
                    glass[i][j][k] = 1;
                }
            }
        }

        // 执行切割操作
        for (int i = 0; i < q; i++) {
            int x1 = sc.nextInt();
            int y1 = sc.nextInt();
            int z1 = sc.nextInt();
            int x2 = sc.nextInt();
            int y2 = sc.nextInt();
            int z2 = sc.nextInt();

            // 根据切割参数修改立方体中的小方块状态
            for (int j = x1; j <= x2; j++) {
                for (int k = y1; k <= y2; k++) {
                    for (int l = z1; l <= z2; l++) {
                        glass[j][k][l] = 0;
                    }
                }
            }
        }

        // 计算剩余的小方块体积
        int remainingVolume = 0;
        for (int i = 1; i <= w; i++) {
            for (int j = 1; j <= x; j++) {
                for (int k = 1; k <= h; k++) {
                    remainingVolume += glass[i][j][k];
                }
            }
        }

        // 输出结果
        System.out.println(remainingVolume);
    }
}
